﻿using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using Xpom_Xpum__Integrated_Development_Environment.Model;

namespace Xpom_Xpum__Integrated_Development_Environment.ViewModel
{
    public class ChooseTemplateWindowViewModel
    {
        #region Constructor

        public ChooseTemplateWindowViewModel()
        {
            mTemplates = new List<Template>();

            var tzpath = AppDomain.CurrentDomain.BaseDirectory + "Templates/";
            foreach (var d in Directory.GetDirectories(tzpath))
            {
                if (File.Exists(d + "\\Template.json"))
                {
                    var t = JsonConvert.DeserializeObject<Template>(File.ReadAllText(d + "\\Template.json"));

                    mTemplates.Add(t);
                }
            }
        }

        #endregion

        #region Commands

        #endregion

        #region Fields

        public List<Template> mTemplates;

        #endregion

        #region Properties

        public List<Template> Templates
        {
            get
            {
                return mTemplates;
            }
        }

        #endregion

        #region Methods

        #endregion

    }
}
